﻿jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
    this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    return this;
}    
$(function(){    
    if(window!=top)
    {
        top.location.href = location.href;
    }
    $("#content").center();
    $(window).bind("resize",function(){        
        $("#content").center();
    });
    $( "#ChangePass" ).dialog({
        autoOpen: false,
        closeOnEscape: false,
        modal: true,
        draggable: false,
        resizable: false,
        open: function(event,ui){ $(".ui-dialog-titlebar-close").hide(); }
    });
    $("body > div[role=dialog]").appendTo("form#form1");
    $("#LoginIn").click(function(){
        var pass1 = $.trim($("#User_Login").val());
        var pass2 = $.trim($("#User_Pass").val());
        if(pass1.length == 0 || pass2.length == 0)
        {
            $("#EmptyToolip").show();
            $("#User_Login").focus();
            return false;
        }
    });
    $("#BtnSave").click(function(){
        var pass1 = $.trim($("#User_Pass_R").val());
        var pass2 = $.trim($("#User_Pass_RT").val());
        if(pass1.length < 6)
        {
            alert("请输入新密码（6-15位）！");
            $("#User_Pass_R").focus();
            return false;
        }
        if(pass2.length < 6)
        {
            alert("请再次输入新密码（6-15位）！");
            $("#User_Pass_RT").focus();
            return false;
        }
        if(pass1 != pass2)
        {
            alert("两次输入密码不一致！");
            $("#User_Pass_R").focus();
            return false;
        }
    });  
    $("#User_Pass_RT").keyup(function(event){
      if(event.keyCode == 13){
        $("#BtnSave").click();
      }
    });  
});

